/*
 * ExecutorService.h
 *
 *  Created on: Sep 17, 2016
 *      Author: root
 */

#ifndef BASE_CONCURRENT_YEXECUTORSERVICE_H_
#define BASE_CONCURRENT_YEXECUTORSERVICE_H_
#include "yBlockingQueue.h"
#include "../yCommon.h"
typedef struct {
	void (*rFun)(void * param);
	void* data;
} task;

class ExecutorService {
public:
	bool running;
	BlockingQueue queue;
	static ExecutorService* newFixedThreadPool(int n);
	void excute(task* tsk);
	void shutdown();
	ExecutorService(int n);
	~ExecutorService();
private:
	int threadNum;
	pthread_t* worker;
	static void * createWorkerThread(void* arg);
};

#endif /* BASE_CONCURRENT_YEXECUTORSERVICE_H_ */
